<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<html>
<head>
	<c:import url="css.jsp"></c:import>    
</head>
<body>
<c:import url="header.jsp"></c:import>
	<div id="content">
<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'add')  }">
	<form action="addTitle.do" method="post" >
		${error } </br>
		${result}<br/>
		ISBN : <input name="isbn" /> </br>
		Name:  <input name="name" /> <br/>
		<input type="submit" value="add" />
	</form>
</c:if>

<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'remove')  }">
	${result}
	<c:forEach items="${ titles}" var="title">
		${ title.isbn } - ${ title.name }  <a href="removeTitle.do?isbn=${title.isbn}"> remove </a> </br>
	</c:forEach>
</c:if>
<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'update')  }">
	${result}
	<c:forEach items="${ titles}" var="title">
		${ title.isbn } - ${ title.name }  <a href="#" onclick="document.getElementById('${title}').style.display='block'"> update </a> </br>
		<div id="${title}" style="display:none">
			<form action="updateTitle.do" method="post" >
				${error } </br>
				${result}<br/>
				 <input type="hidden" name="isbn" value="${title.isbn }" />
				ISBN : <input value="${title.isbn }" disabled="disabled" /> </br>
				Name:  <input name="name" value="${title.name }" /> <br/>
				<input type="submit" value="update" />
			</form>
		</div>
	</c:forEach>
</c:if>
<c:if test="${ fn:contains(requestScope['javax.servlet.forward.servlet_path'] , 'display')  }">
	${result}
	
<div id ="title">The library has the following titles : </div>
<table  class="gridtable">
<thead>
<tr>
<th scope="col">ISBN</th>
<th scope="col">Name </th>
<th scope="col">Available Copies</th>
</tr>
</thead>
	<c:forEach items="${ titles}" var="title">

<tbody>
<tr>
<td>${ title.isbn }</td>
<td>${ title.name } </td>
<td> <a href="showItem.do?isbn=${title.isbn}">Check available copies</a> </td>
</tr>

	</c:forEach>
	</tbody>
</table>
</c:if>

</div>
	
</body>
</html>